package org.opens.netty.encoder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.opens.netty.util.ByteUtil;

public class ApplicationLayerEncoder extends MessageToByteEncoder<ApplicationLayer> {

    @Override
    protected void encode(ChannelHandlerContext ctx, ApplicationLayer msg, ByteBuf out) throws Exception {
        out.writeBytes(ByteUtil.hexStringToByteArray(msg.getSrc()));
        out.writeBytes(ByteUtil.hexStringToByteArray(msg.getDesc()));
        out.writeBytes(ByteUtil.hexStringToByteArray(msg.getBpdu()));
    }

}
